package com.haotunet.app.goldtreasure.views;

import com.haotunet.app.goldtreasure.R;
import com.haotunet.app.goldtreasure.other.Interface.OnValueSetClickListener;
import com.haotunet.app.goldtreasure.utils.UIHelper;
import android.app.Dialog;
import android.content.Context;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class ChangePhoneDialog extends Dialog implements android.view.View.OnClickListener {
	private LayoutInflater mLayoutInflater;
	private Context mcontext;
	private View rootView;
	private Button btnSure;
	private EditText etPhone;
	private OnValueSetClickListener mListener;

	public ChangePhoneDialog(Context context, int theme) {
		super(context, theme);
		mcontext = context;
		mLayoutInflater = (LayoutInflater) mcontext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		initViews();
	}

	private void initViews() {
		rootView = mLayoutInflater.inflate(R.layout.dialog_change_phone, null);
		setContentView(rootView);
		etPhone = (EditText) rootView.findViewById(R.id.et_phone);
		btnSure = (Button) rootView.findViewById(R.id.btn_sure);
		btnSure.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.btn_sure:
			String phone = etPhone.getText().toString().trim();
			if (TextUtils.isEmpty(phone)) {
				UIHelper.showToast(mcontext, "请输入手机号!");
				return;
			}
			mListener.onValueSet(phone);
			dismiss();
			break;

		default:
			break;
		}
	}

	public void setValueSetClickListener(OnValueSetClickListener listener) {
		mListener = listener;
	}
}
